#include <iostream>
using namespace std;
struct twoint{
int first, second;
twoint(int _first, int _second): first(_first), second(_second){}
};
template <typename T>
T Minimum(T* arr, int size){
T min=arr[0];
for(int i=1; i<size; ++i){
if(min>arr[i]) min=arr[i];
}
return min;
}
template <typename T>
T Maximum(T* arr, int size){
T max=arr[0];
for(int i=1; i<size; ++i){
if(max<arr[i]) max=arr[i];
}
return max;
}
template <typename T>
twoint MinMax(T* arr, int size){
int min, max, crt_min, crt_max, start;
if(size%2==0){
if(arr[0]>arr[1]){
min=arr[1]; max=arr[0];
} else {
min=arr[0]; max=arr[1];
}
start=2;
} else {
min=arr[0]; max=arr[0];
start=1;
}
for(int i=start; i<size; i+=2){
if(arr[i]>arr[i+1]){
crt_min=arr[i+1]; crt_max=arr[i];
} else {
crt_min=arr[i]; crt_max=arr[i+1];
}
if(min>crt_min) min=crt_min;
if(max<crt_max) max=crt_max;
}
return twoint(min, max);
}
int main(void){
int arr[]={3, 4, 6, 7, 9, 11, 15};
int size=sizeof(arr)/sizeof(int);
cout<<"Minimum: "<<Minimum<int>(arr, size)<<'\n';
cout<<"Maximum: "<<Maximum<int>(arr, size)<<endl;
twoint result=MinMax(arr, size);
cout<<"Min: "<<result.first<<" Max: "<<result.second<<endl;
return 0;
}